package  com.kdgc.power.base.controller;

import com.kdgc.power.base.entity.BaseMoney;
import com.kdgc.power.base.service.BaseMoneyService;
import com.kdgc.power.fw.bean.JsonMsg;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.servlet.http.HttpServletRequest;

import java.util.Map;

@Controller
@RequestMapping("BaseMoney")
public class BaseMoneyController {
    @Autowired
    private BaseMoneyService baseMoneyService;

    @ResponseBody
    @RequestMapping("page")
    public Object getPage(HttpServletRequest request, int page, int rows) {
        return  baseMoneyService.getPage( "baseMoney.select", null, page, rows);
    }

    @ResponseBody
    @RequestMapping("findById")
    public Map<String,Object> findById(Integer id) {
        return  baseMoneyService.getMapEntity(id);
    }

    @ResponseBody
    @RequestMapping("save")
    public JsonMsg save(BaseMoney entity) {
        boolean success = baseMoneyService.saveOrUpdate(entity);
        return new JsonMsg(success);
    }

    @ResponseBody
    @RequestMapping("deleteById")
    public JsonMsg deleteById(Integer id) {
        int rows = baseMoneyService.removeById(id);
        return new JsonMsg(rows == 1);
    }
}